<%-- 
    Document   : admin_Grade
    Created on : 2020-5-18, 8:30:09
    Author     : liqianru
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>成绩管理</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!--图标样式-->
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <!--主要样式-->
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <link rel="stylesheet" href="css/mycss_foradim.css"/>
        <script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
        <script type="text/javascript" src="js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/circle.js" charset="UTF-8"></script>
    </head>
    <body onload="goPage(1, 20)">
        <script>
            $(function () {
                setInterval(function () {

                    $.ajax({
                        url: 'admin_modifyStatus',
                        type: 'post',
                        async: false,
                        data: {admin_action: "search_status"},
                        success: function (data) {//status 表示申请状态：：0表示未申请
                            if (data < 1) {

                                $(".redpoint").css("display", "inline-block");
                                $("#status_li").css("display", "block");

                            }
                            if (data > 0) {
                                $(".redpoint").css("display", "none");
                                $("#status_li").css("display", "none");
                            }

                        },
                        error: function () {
                           // alert("error");
                           console.log("meg_error");
                        }

                    });
                }, 500);
            });

        </script>
        <div id="navdiv">
            <div class="top_navdiv">
                <div class="top_left">管理员中心</div>
                <div class="identity">
                    <span class="message">您好</span><span class="redpoint">1</span>
                    <div class="user_li">
                        <canvas id="myCanvas" width="100" height="30">
                        </canvas>
                    </div>
                    <div class="nd_menu">
                        <ol>
                            <li>回到首页</li>
                            <li><a href="#" onclick="all_logout()">退出登录</a></li>
                            <li id="status_li"><a onclick="refresh()" href="#" data-target="#myModal_status" data-toggle="modal">申请信息</a><span class="redpoint" id="status_span">1</span></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <div class="control_nav ">
            <div class="container">
                <ul class="nav navbar-nav navul">

                   <li class="col-md-2 nav_li">
                        <a href="#"><img class="nav_img" src="img/nav6.png"/> 教师</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                    <li class="col-md-2 nav_li">
                        <a href="#"><img class="nav_img" src="img/nav1.png"/> 班级</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                    <li class="col-md-2">
                        <a href="getallStu?action=getall"><img class="nav_img" src="img/nav5.png"/> 学生</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                    <li class="col-md-2">
                        <a href="getallCourse?action1=getall"><img class="nav_img" src="img/nav3.png"/> 课程</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                    <li class="col-md-2">
                        <a href="getallschedule"><img class="nav_img" src="img/nav2.png"/> 带课</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                    <li class="col-md-2">
                        <a href="getTest?action=get"><img class="nav_img" src="img/nav4.png"/> 题目</a>
                        <div class="nav_underline" style="display: none;"></div>
                    </li>
                </ul>
            </div>
        </div>
        <div class="container">
            
            <div class="main_div">
                <form>
                    <input type="text" class="input-lg col-lg-2" name="keyword" placeholder="输入关键字查询" id="keyword_input">
                    <input type="text" hidden="true" name="action" value="search">
                    <button  class="btn btn-lg btn-toolbar search_btn col-xs-1" formaction="admin_getGrade" formmethod="GET" >
                        <span class="glyphicon glyphicon-search"></span>
                    </button>
                </form>
                <a href="admin_getGrade?action=getall" type="button" class="btn btn-sm re_Stu_btn re_text_btn " ><span class="glyphicon glyphicon-repeat">刷新列表</span></a>
                <br><table class="table-striped test_table table-hover table-condensed" id="Stu_table">
                    <tr>
                        <td class="col-md-2 table-td">学号</td>
                        <td class="col-md-2 table-td">姓名</td>
                        <td class="col-md-2 table-td">班级名</td>
                        <td class="col-md-3 table-td">课程名</td>
                        <td class="col-md-2 table-td">成绩</td>
                        <td class="col-md-1 table-td">操作</td>

                    </tr>
                    <c:forEach items="${requestScope.gradeList}" var="g"> 
                        <tr id="tr${g.sid }" class="table-hover forEach_tr">
                            <td class="col-md-2 table-nd-td" id="id${g.sid }"><a href="#" class="table-nd-td">${g.sid}</a></td>
                            <td class="col-md-2 table-nd-td" id="name${g.sid }"><a href="#" class="table-nd-td">${g.sname}</a></td>
                            <td class="col-md-2 table-nd-td" id="clname${g.sid }">${g.className}</td>
                            <td class="col-md-2 table-nd-td" id="couname${g.sid }">${g.courseName}</td>
                            <c:choose>
                                <c:when test="${g.grade>=60}">
                                    <td class="col-md-2 table-nd-td text-success" id="grade${g.sid }">${g.grade}</td>
                                </c:when>
                                <c:otherwise>
                                    <td class="col-md-2 table-nd-td text-danger" id="grade${g.sid }">${g.grade}</td>
                                </c:otherwise>
                            </c:choose>
                            <td class="col-md-2 table-nd-td" id="oper${g.sid }"><a href="#" onclick="showGra_details(${g.sid })" class="grade_a text-info" data-target="#myModal_modify" data-toggle="modal"> &nbsp;修改</a></td>
                        </tr>
                    </c:forEach>
                </table>
                <div id="barcon" name="barcon" class="index_div"></div>
                <!--编辑弹窗-->
                <div class="modal fade" id="myModal_modify" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog">
                        <div class="modal-content modal_div">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">修改学生成绩</h4>
                            </div>
                            <div class="modal-body">
                                <form id="modify_form" class="modal_form">
                                    <label for="name">学生姓名：</label>
                                    <input type="text" id="name" class="form-control modal_input" name="sname" readonly>
                                    <label for="sid">学号：</label>
                                    <input type="text" id="sid" class="form-control modal_input"  name="sid" readonly="true">
                                    <label for="classid">班级：</label>
                                    <input type="text" name="classid" id="classid"  class="form-control modal_input" readonly>
                                    <label for="grade">成绩</label>
                                    <input type="text" id="grade" name="grade" class="form-control modal_input">
                                    <input type="text" id="coursename" name="coursename" value="1" hidden>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-primary" id="submit_btn" onclick="modify()">提交</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!--编辑确认窗口-->
                <div class="modal fade" id="myModal_status" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">确认</h4>
                            </div>
                            <div class="modal-body">
                                <p>确认批准考试编号为:<b>${sessionScope.testid}</b>的申请吗？</p>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-primary" id="submit_btn" onclick="modify_status(${sessionScope.testid})">确认</button>
                                <button type="button" class="btn btn-default" id="submit_btn" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            function showGra_details(rollnum) {
                $("#myModal_modify #sid").val($("#id" + rollnum).text());
                $("#myModal_modify #name").val($("#name" + rollnum).text());
                $("#myModal_modify #classid").val($("#clname" + rollnum).text());
                $("#myModal_modify #grade").val($("#grade" + rollnum).text());
                $("#myModal_modify #coursename").val($("#couname" + rollnum).text());
            }
            function modify() {
                $.ajax({
                    url: "operaCourse",
                    type: 'POST',
                    data: {sid: $("#myModal_modify #sid").val(), grade: $("#myModal_modify #grade").val(), action: "updateGrade",coursename:$("#myModal_modify #coursename").val()},
                    success: function (rows) {
                        if (rows > 0) {
                            alert("success");
                            $("#myModal_modify").modal('hide');
                            window.location.reload();
                        }
                    },
                    error: function () {
                        alert("error");
                    }
                });
            }
            function modify_status(testid) {
                $.ajax({
                    url: 'admin_modifyStatus',
                    type: 'post',
                    async: false,
                    data: {admin_action: "modify_status"},
                    success: function (data) {//status 表示申请状态：：0表示未申请
                        $("#myModal_status").modal('hide');

                    },
                    error: function () {
                        alert("error");
                    }

                });
            }
        </script>
    </body>
</html>
